package top.archiesean.common.core.config;

import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.http.converter.json.GsonHttpMessageConverter;
import top.archiesean.common.core.utils.gson.GsonUtil;

/**
 * @author ArchieSean
 * @description 核心配置类
 * @date 2024-01-02 07:02
 */
@AutoConfiguration
@AutoConfigureBefore(HttpMessageConvertersAutoConfiguration.class)
public class CoreConfiguration {
    /**
     * 由gson接管消息转换，包含了Long转str
     *
     * @return HttpMessageConverters
     */
    @Bean
    @ConditionalOnMissingBean
    public HttpMessageConverters gsonHttpMessageConverter() {
        GsonHttpMessageConverter converter = new GsonHttpMessageConverter(GsonUtil.getGson());
        return new HttpMessageConverters(converter);
    }
}
